/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.cmc.service.merchant.model;

import com.cmc.service.merchant.service.MerchantEntryLocalServiceUtil;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.model.BaseModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.util.PortalUtil;

import java.io.Serializable;

import java.lang.reflect.Proxy;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * @author ntcuong1
 */
public class MerchantEntryClp extends BaseModelImpl<MerchantEntry>
	implements MerchantEntry {
	public MerchantEntryClp() {
	}

	public Class<?> getModelClass() {
		return MerchantEntry.class;
	}

	public String getModelClassName() {
		return MerchantEntry.class.getName();
	}

	public long getPrimaryKey() {
		return _merchantId;
	}

	public void setPrimaryKey(long primaryKey) {
		setMerchantId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_merchantId);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	@Override
	public Map<String, Object> getModelAttributes() {
		Map<String, Object> attributes = new HashMap<String, Object>();

		attributes.put("merchantId", getMerchantId());
		attributes.put("companyId", getCompanyId());
		attributes.put("creatorUserId", getCreatorUserId());
		attributes.put("createDate", getCreateDate());
		attributes.put("modifiedDate", getModifiedDate());
		attributes.put("type", getType());
		attributes.put("code", getCode());
		attributes.put("title", getTitle());
		attributes.put("description", getDescription());
		attributes.put("organization", getOrganization());
		attributes.put("organizationId", getOrganizationId());
		attributes.put("organizationType", getOrganizationType());
		attributes.put("organizationStatus", getOrganizationStatus());
		attributes.put("sites", getSites());
		attributes.put("recursable", getRecursable());
		attributes.put("countryId", getCountryId());
		attributes.put("regionId", getRegionId());
		attributes.put("longitude", getLongitude());
		attributes.put("latitude", getLatitude());
		attributes.put("parentId", getParentId());

		return attributes;
	}

	@Override
	public void setModelAttributes(Map<String, Object> attributes) {
		Long merchantId = (Long)attributes.get("merchantId");

		if (merchantId != null) {
			setMerchantId(merchantId);
		}

		Long companyId = (Long)attributes.get("companyId");

		if (companyId != null) {
			setCompanyId(companyId);
		}

		Long creatorUserId = (Long)attributes.get("creatorUserId");

		if (creatorUserId != null) {
			setCreatorUserId(creatorUserId);
		}

		Date createDate = (Date)attributes.get("createDate");

		if (createDate != null) {
			setCreateDate(createDate);
		}

		Date modifiedDate = (Date)attributes.get("modifiedDate");

		if (modifiedDate != null) {
			setModifiedDate(modifiedDate);
		}

		String type = (String)attributes.get("type");

		if (type != null) {
			setType(type);
		}

		String code = (String)attributes.get("code");

		if (code != null) {
			setCode(code);
		}

		String title = (String)attributes.get("title");

		if (title != null) {
			setTitle(title);
		}

		String description = (String)attributes.get("description");

		if (description != null) {
			setDescription(description);
		}

		Boolean organization = (Boolean)attributes.get("organization");

		if (organization != null) {
			setOrganization(organization);
		}

		Long organizationId = (Long)attributes.get("organizationId");

		if (organizationId != null) {
			setOrganizationId(organizationId);
		}

		String organizationType = (String)attributes.get("organizationType");

		if (organizationType != null) {
			setOrganizationType(organizationType);
		}

		Integer organizationStatus = (Integer)attributes.get(
				"organizationStatus");

		if (organizationStatus != null) {
			setOrganizationStatus(organizationStatus);
		}

		Boolean sites = (Boolean)attributes.get("sites");

		if (sites != null) {
			setSites(sites);
		}

		Boolean recursable = (Boolean)attributes.get("recursable");

		if (recursable != null) {
			setRecursable(recursable);
		}

		Long countryId = (Long)attributes.get("countryId");

		if (countryId != null) {
			setCountryId(countryId);
		}

		Long regionId = (Long)attributes.get("regionId");

		if (regionId != null) {
			setRegionId(regionId);
		}

		Double longitude = (Double)attributes.get("longitude");

		if (longitude != null) {
			setLongitude(longitude);
		}

		Double latitude = (Double)attributes.get("latitude");

		if (latitude != null) {
			setLatitude(latitude);
		}

		Long parentId = (Long)attributes.get("parentId");

		if (parentId != null) {
			setParentId(parentId);
		}
	}

	public long getMerchantId() {
		return _merchantId;
	}

	public void setMerchantId(long merchantId) {
		_merchantId = merchantId;
	}

	public long getCompanyId() {
		return _companyId;
	}

	public void setCompanyId(long companyId) {
		_companyId = companyId;
	}

	public long getCreatorUserId() {
		return _creatorUserId;
	}

	public void setCreatorUserId(long creatorUserId) {
		_creatorUserId = creatorUserId;
	}

	public String getCreatorUserUuid() throws SystemException {
		return PortalUtil.getUserValue(getCreatorUserId(), "uuid",
			_creatorUserUuid);
	}

	public void setCreatorUserUuid(String creatorUserUuid) {
		_creatorUserUuid = creatorUserUuid;
	}

	public Date getCreateDate() {
		return _createDate;
	}

	public void setCreateDate(Date createDate) {
		_createDate = createDate;
	}

	public Date getModifiedDate() {
		return _modifiedDate;
	}

	public void setModifiedDate(Date modifiedDate) {
		_modifiedDate = modifiedDate;
	}

	public String getType() {
		return _type;
	}

	public void setType(String type) {
		_type = type;
	}

	public String getCode() {
		return _code;
	}

	public void setCode(String code) {
		_code = code;
	}

	public String getTitle() {
		return _title;
	}

	public void setTitle(String title) {
		_title = title;
	}

	public String getDescription() {
		return _description;
	}

	public void setDescription(String description) {
		_description = description;
	}

	public boolean getOrganization() {
		return _organization;
	}

	public boolean isOrganization() {
		return _organization;
	}

	public void setOrganization(boolean organization) {
		_organization = organization;
	}

	public long getOrganizationId() {
		return _organizationId;
	}

	public void setOrganizationId(long organizationId) {
		_organizationId = organizationId;
	}

	public String getOrganizationType() {
		return _organizationType;
	}

	public void setOrganizationType(String organizationType) {
		_organizationType = organizationType;
	}

	public int getOrganizationStatus() {
		return _organizationStatus;
	}

	public void setOrganizationStatus(int organizationStatus) {
		_organizationStatus = organizationStatus;
	}

	public boolean getSites() {
		return _sites;
	}

	public boolean isSites() {
		return _sites;
	}

	public void setSites(boolean sites) {
		_sites = sites;
	}

	public boolean getRecursable() {
		return _recursable;
	}

	public boolean isRecursable() {
		return _recursable;
	}

	public void setRecursable(boolean recursable) {
		_recursable = recursable;
	}

	public long getCountryId() {
		return _countryId;
	}

	public void setCountryId(long countryId) {
		_countryId = countryId;
	}

	public long getRegionId() {
		return _regionId;
	}

	public void setRegionId(long regionId) {
		_regionId = regionId;
	}

	public double getLongitude() {
		return _longitude;
	}

	public void setLongitude(double longitude) {
		_longitude = longitude;
	}

	public double getLatitude() {
		return _latitude;
	}

	public void setLatitude(double latitude) {
		_latitude = latitude;
	}

	public long getParentId() {
		return _parentId;
	}

	public void setParentId(long parentId) {
		_parentId = parentId;
	}

	public BaseModel<?> getMerchantEntryRemoteModel() {
		return _merchantEntryRemoteModel;
	}

	public void setMerchantEntryRemoteModel(
		BaseModel<?> merchantEntryRemoteModel) {
		_merchantEntryRemoteModel = merchantEntryRemoteModel;
	}

	public void persist() throws SystemException {
		if (this.isNew()) {
			MerchantEntryLocalServiceUtil.addMerchantEntry(this);
		}
		else {
			MerchantEntryLocalServiceUtil.updateMerchantEntry(this);
		}
	}

	@Override
	public MerchantEntry toEscapedModel() {
		return (MerchantEntry)Proxy.newProxyInstance(MerchantEntry.class.getClassLoader(),
			new Class[] { MerchantEntry.class }, new AutoEscapeBeanHandler(this));
	}

	@Override
	public Object clone() {
		MerchantEntryClp clone = new MerchantEntryClp();

		clone.setMerchantId(getMerchantId());
		clone.setCompanyId(getCompanyId());
		clone.setCreatorUserId(getCreatorUserId());
		clone.setCreateDate(getCreateDate());
		clone.setModifiedDate(getModifiedDate());
		clone.setType(getType());
		clone.setCode(getCode());
		clone.setTitle(getTitle());
		clone.setDescription(getDescription());
		clone.setOrganization(getOrganization());
		clone.setOrganizationId(getOrganizationId());
		clone.setOrganizationType(getOrganizationType());
		clone.setOrganizationStatus(getOrganizationStatus());
		clone.setSites(getSites());
		clone.setRecursable(getRecursable());
		clone.setCountryId(getCountryId());
		clone.setRegionId(getRegionId());
		clone.setLongitude(getLongitude());
		clone.setLatitude(getLatitude());
		clone.setParentId(getParentId());

		return clone;
	}

	public int compareTo(MerchantEntry merchantEntry) {
		int value = 0;

		value = getTitle().compareTo(merchantEntry.getTitle());

		if (value != 0) {
			return value;
		}

		value = getCode().compareTo(merchantEntry.getCode());

		if (value != 0) {
			return value;
		}

		return 0;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		MerchantEntryClp merchantEntry = null;

		try {
			merchantEntry = (MerchantEntryClp)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long primaryKey = merchantEntry.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(41);

		sb.append("{merchantId=");
		sb.append(getMerchantId());
		sb.append(", companyId=");
		sb.append(getCompanyId());
		sb.append(", creatorUserId=");
		sb.append(getCreatorUserId());
		sb.append(", createDate=");
		sb.append(getCreateDate());
		sb.append(", modifiedDate=");
		sb.append(getModifiedDate());
		sb.append(", type=");
		sb.append(getType());
		sb.append(", code=");
		sb.append(getCode());
		sb.append(", title=");
		sb.append(getTitle());
		sb.append(", description=");
		sb.append(getDescription());
		sb.append(", organization=");
		sb.append(getOrganization());
		sb.append(", organizationId=");
		sb.append(getOrganizationId());
		sb.append(", organizationType=");
		sb.append(getOrganizationType());
		sb.append(", organizationStatus=");
		sb.append(getOrganizationStatus());
		sb.append(", sites=");
		sb.append(getSites());
		sb.append(", recursable=");
		sb.append(getRecursable());
		sb.append(", countryId=");
		sb.append(getCountryId());
		sb.append(", regionId=");
		sb.append(getRegionId());
		sb.append(", longitude=");
		sb.append(getLongitude());
		sb.append(", latitude=");
		sb.append(getLatitude());
		sb.append(", parentId=");
		sb.append(getParentId());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(64);

		sb.append("<model><model-name>");
		sb.append("com.cmc.service.merchant.model.MerchantEntry");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>merchantId</column-name><column-value><![CDATA[");
		sb.append(getMerchantId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>companyId</column-name><column-value><![CDATA[");
		sb.append(getCompanyId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>creatorUserId</column-name><column-value><![CDATA[");
		sb.append(getCreatorUserId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>createDate</column-name><column-value><![CDATA[");
		sb.append(getCreateDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
		sb.append(getModifiedDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>type</column-name><column-value><![CDATA[");
		sb.append(getType());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>code</column-name><column-value><![CDATA[");
		sb.append(getCode());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>title</column-name><column-value><![CDATA[");
		sb.append(getTitle());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>description</column-name><column-value><![CDATA[");
		sb.append(getDescription());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>organization</column-name><column-value><![CDATA[");
		sb.append(getOrganization());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>organizationId</column-name><column-value><![CDATA[");
		sb.append(getOrganizationId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>organizationType</column-name><column-value><![CDATA[");
		sb.append(getOrganizationType());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>organizationStatus</column-name><column-value><![CDATA[");
		sb.append(getOrganizationStatus());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>sites</column-name><column-value><![CDATA[");
		sb.append(getSites());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>recursable</column-name><column-value><![CDATA[");
		sb.append(getRecursable());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>countryId</column-name><column-value><![CDATA[");
		sb.append(getCountryId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>regionId</column-name><column-value><![CDATA[");
		sb.append(getRegionId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>longitude</column-name><column-value><![CDATA[");
		sb.append(getLongitude());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>latitude</column-name><column-value><![CDATA[");
		sb.append(getLatitude());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>parentId</column-name><column-value><![CDATA[");
		sb.append(getParentId());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private long _merchantId;
	private long _companyId;
	private long _creatorUserId;
	private String _creatorUserUuid;
	private Date _createDate;
	private Date _modifiedDate;
	private String _type;
	private String _code;
	private String _title;
	private String _description;
	private boolean _organization;
	private long _organizationId;
	private String _organizationType;
	private int _organizationStatus;
	private boolean _sites;
	private boolean _recursable;
	private long _countryId;
	private long _regionId;
	private double _longitude;
	private double _latitude;
	private long _parentId;
	private BaseModel<?> _merchantEntryRemoteModel;
}